/* 
 * File:   primitives.h
 * Author: gustavo
 *
 * Created on August 6, 2011, 4:28 AM
 */

#ifndef PRIMITIVES_H
#define	PRIMITIVES_H

#include "types.h"

#include "../matrix/matrix.h"

#ifdef	__cplusplus
extern "C" {
#endif

	typedef struct _point2d Point2D;
	typedef struct _edge2d Edge2D;
	typedef struct _vertex Vertex;
	typedef struct _vertex_list VertexList;

	struct _point2d {
		int x;
		int y;
	};

	struct _edge2d {
		long int idx;
		Point2D p1;
		Point2D p2;
	};

	struct _vertex {
		long idx;
		Point2D p;
		boolean ear;
		struct _vertex * next;
		struct _vertex * prev;
	};

	struct _vertex_list {
		long int size;

		Vertex * first;
		Vertex * last;
	};
	
	typedef struct _point Point;
	struct _point {
		int type;
		int dim;
		void * data;
	};
	
	struct __point2d {
		struct _point p;
	};
	
	struct _polygon {
		VertexList VL;
	};
	
	

	VertexList * imp_get_vertex_list_from_matrix(Matrix * Mat);
	VertexList * imp_get_convex_hull(VertexList * VL);

	void imp_sort_vertex_list(VertexList * VL);

#ifdef	__cplusplus
}
#endif

#endif	/* PRIMITIVES_H */

